#!/bin/sh -e

for patch in *.patch; do
    patch -p1 < "$patch"
done

# Don't link against execinfo.h.
sed -i 's/define QLOG/define N/g' \
    ./src/corelib/global/qlogging.cpp

./configure \
    -confirm-license \
    -opensource \
    -prefix /usr \
    -docdir /usr/share/doc/qt \
    -headerdir /usr/include/qt \
    -archdatadir /usr/lib/qt \
    -datadir /usr/share/qt \
    -sysconfdir /etc/xdg \
    -examplesdir /usr/share/doc/qt/examples \
    -nomake examples \
    -nomake tests \
    -optimized-qmake \
    -no-libudev \
    -no-separate-debug-info \
    -no-pch \
    -no-dbus \
    -no-accessibility \
    -no-gtk \
    -no-glib \
    -system-libjpeg \
    -system-libpng \
    -system-sqlite \
    -system-zlib \
    -system-freetype \
    -system-harfbuzz \
    -silent 

make
make INSTALL_ROOT="$1" install

install -Dm755 qt.conf "$1/usr/bin/qt.conf"
